| Conditions | 2 | 
| Paths | 2 | 
| Total Lines | 25 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 0 | ||
| 1 | wp.customize.controlConstructor['kirki-code'] = wp.customize.kirkiDynamicControl.extend({ | 
            ||
| 3 | 	initKirkiControl: function() { | 
            ||
| 4 | |||
| 5 | var control = this;  | 
            ||
| 
                                                                                                    
                        
                         | 
                |||
| 6 | |||
| 7 | // Early exit if wp.customize.CodeEditorControl is not available.  | 
            ||
| 8 | 		if ( _.isUndefined( wp.customize.CodeEditorControl ) ) { | 
            ||
| 9 | return;  | 
            ||
| 10 | }  | 
            ||
| 11 | |||
| 12 | // Hide the textarea.  | 
            ||
| 13 | jQuery( control.container.find( 'textarea.kirki-codemirror-editor' ) ).hide();  | 
            ||
| 14 | |||
| 15 | // Add the control.  | 
            ||
| 16 | 		wp.customize.control.add( new wp.customize.CodeEditorControl( control.id, { | 
            ||
| 17 | section: control.params.section,  | 
            ||
| 18 | priority: control.params.priority,  | 
            ||
| 19 | label: control.params.label,  | 
            ||
| 20 | 			editor_settings: { | 
            ||
| 21 | 				codemirror: { | 
            ||
| 22 | mode: control.params.choices.language  | 
            ||
| 23 | }  | 
            ||
| 24 | },  | 
            ||
| 25 | 			settings: { 'default': control.id } | 
            ||
| 26 | } ) );  | 
            ||
| 27 | }  | 
            ||
| 28 | });  | 
            ||
| 29 | 
Since ECMAScript 6, you can create block-scoped vars or constants with the keywords
letorconst. These variables/constants are only valid in the code block where they have been declared.Consider the following two pieces of code:
and
The variable is not defined otuside of its block. This limits bleeding of variables into other contexts.
To know more about this ECMA6 feature, look at the MDN pages on let and const.